const express = require('express');
const router = express.Router();

const list =  [
    {
        "taskId": 18,
        "taskContent": "我的任务0031",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": "来自老板的任务",
        "finishStatus": 1,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-01 16:05:20",
        "assignId": null,
        "shareDateTime": null,
        "fromId": 15,
        steps:[
            {
                id:1,
                title:"第一步",
                finish:1
            },
            {
                id:2,
                title:"第二步",
                finish:1
            },
            {
                id:3,
                title:"第三步",
                finish:0
            }
        ]
    },
    {
        "taskId": 19,
        "taskContent": "我的任务0032",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": "来自老板的任务",
        "finishStatus": 1,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-01 16:05:20",
        "assignId": null,
        "shareDateTime": null,
        "fromId": 15
    },
    {
        "taskId": 20,
        "taskContent": "我的任务0033",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": "分发给员工的任务",
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 15,
        "createDateTime": "2025-03-01 16:31:47",
        "assignId": 14,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 21,
        "taskContent": "我的任务0034",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": "老板自己的任务",
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 15,
        "createDateTime": "2025-03-01 16:31:47",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 22,
        "taskContent": "我的任务0035",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": "员工自己的任务",
        "finishStatus": 1,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-01 17:14:45",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 23,
        "taskContent": "我的任务0021",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": null,
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-01 17:14:57",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 24,
        "taskContent": "我的任务0011",
        "flag": 1,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": null,
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-01 20:11:24",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 25,
        "taskContent": "我的任务0021",
        "flag": 1,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": null,
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-01 20:11:25",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 32,
        "taskContent": "我的任务0014",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": null,
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-02 08:58:07",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    },
    {
        "taskId": 33,
        "taskContent": "我的任务0025",
        "flag": 0,
        "noticeDateTime": null,
        "endDateTime": null,
        "fileData": null,
        "note": null,
        "finishStatus": 0,
        "confirmUserId": 16,
        "confirmDateTime": null,
        "createID": 14,
        "createDateTime": "2025-03-02 08:58:22",
        "assignId": null,
        "shareDateTime": null,
        "fromId": null
    }
]


// 处理 POST 请求，创建新用户
router.post('/api/task/gettask', (req, res) => {


    res.json({
        data: list,
        code: 200
    });
});
router.post('/api/task/updatetask', (req, res) => {
    const { id, ...rest } = JSON.parse(req.body.param)
    const target = list.find(item => item.id === id)
    Object.assign(target, rest)


    res.json({
        "success": true
    });
});
router.get('/test', (req, res) => {


    res.json({
        "success": true
    });
});


module.exports = router;